<?php 
	//for checking current page regarding search results
	if(isset($_GET["addProduct"])) {
		$searchpage = 1;
	} else {
		$searchpage = 0;
	}
?>
<script src="js/spry/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="js/spry/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
function funSearchAll(val) {	
	var frm=document.getElementById(val);
	var spage = frm.spage.value;	
	var jobp=document.getElementById('catId').value;
	//check search page
	if(jobp>1 && jobp<6){
	frm.action="index.php?srchPost&catId="+jobp;
	frm.submit();
	}else{
	
	if(spage=='1') {
		srchPage = "addProduct&";
	} else {
		srchPage = "";
	}
	
	var sg=frm.sg.value; 
	var key=frm.key.value;
	var pf=frm.priceFrom.value; 
	var pt=frm.priceTo.value;
	if(val=='formSearchBuyer'){
	  var st=frm.state.value;  
	  var ct=frm.city.value;
      frm.action="index.php?srchBuyer&sg="+sg+"&key="+key+"&st="+st+"&cty="+ct+"&pf="+pf+"&pt="+pt; 	
	  }
	else if(val!='formSearchOnline')
	{
	  var st=frm.state.value;  
	  var ct=frm.city.value;
	   frm.action="index.php?"+srchPage+"srch&sg="+sg+"&key="+key+"&st="+st+"&cty="+ct+"&pf="+pf+"&pt="+pt;
	}
	else
	   frm.action="index.php?"+srchPage+"srch&sg="+sg+"&key="+key+"&pf="+pf+"&pt="+pt;
	
		
	frm.submit();
	}
}
function showHideBox()
    {
        var divstyle = new String();
        divstyle = document.getElementById("tblPrice").style.visibility;
		if(document.getElementById("catId").value!="")
		{
        
            document.getElementById("tblPrice").style.visibility = "hidden";
       }
        else
        {
            document.getElementById("tblPrice").style.visibility = "visible";
        }
    }
</script>
<script language="javascript">
function tracking(section)
{

	var http;
	 if (window.XMLHttpRequest) {  http = new XMLHttpRequest();	
    } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); }

	http.open('GET',  'ntracking.php?section='+section);
	http.onreadystatechange = function () {
    if(http.readyState == 4){
	
        var response = http.responseText;
		
		
    }
  }
http.send(null);
    


}
</script>
<table width="520" style="border-left: solid 1px #CCC;
	border-bottom: solid 1px #CCC;
	border-top: solid 1px #999;
	border-right: solid 1px #999;">
<tr>
<td>
<div id="TabbedPanels1" class="TabbedPanels">
  <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0" onclick="return tracking('Search All');">Search all</li>
    <li class="TabbedPanelsTab" tabindex="0" onclick="return tracking('Online only');">Online only</li>
    <li class="TabbedPanelsTab" tabindex="0" onclick="return tracking('Buy local');">Buy local</li>
    <?
    if($sellflag!=1)
    {
?>
		  <li class="TabbedPanelsTab" tabindex="0" onclick="return tracking('<?php if($_SESSION['user_type_sess']=="5") { ?>Search Merchant<?php } else {?>Search buyer<?php }?>');"><?php if($_SESSION['user_type_sess']=="5") { ?>Search Merchant<?php } else {?>Search buyer<?php }?></li>
<?
    }
?>
  </ul>
  <div class="TabbedPanelsContentGroup">
    <div class="TabbedPanelsContent"><form name="formSearchAll" id="formSearchAll" method="post" action="">
	<input type="hidden" name="sg" id="sg" value="all">
	<input type="hidden" name="spage" id="spage" value="<?php echo $searchpage; ?>">
<table width="100%" border="0">
  <tr>
    <td width="63%"><input name="key" type="text" id="key" value="<?php 
	if(!empty($_GET['key']))
	 echo $_GET['key']; ?>" size="10" />
    <select name="catId" id="catId" onchange="return showHideBox();">
    <option value="">For Sale</option>
    <option value="2">Jobs</option>
    <option value="3">Rents</option>
    <option value="4">Real Estate</option>
    <option value="5">Services</option>
    </select>
    <input type="submit" value="Search" name="btnSrch" onClick="funSearchAll('formSearchAll');"/> </td>
    <td width="37%"><table width="100%" border="0" id="tblPrice">
      <tr>
        <td colspan="2" align="center">
			<select name="state" id="state" style="width:145px;" onChange="funSelectCity(this.value,'search-city-all');">
				<option value="">..Select State..</option>
				<?php			   
				   $sqlSelState="SELECT * FROM tbl_state where country_id='213'";
				   $rstSelState=mysql_query($sqlSelState);
				   while($rowSelState=mysql_fetch_array($rstSelState))
				   {
				   $st_id=$rowSelState['stateid'];
				   $st_name=$rowSelState['statename'];
				   echo "<option value='$st_id'>$st_name</option>";
				   }
				?>
			</select>		</td>
        </tr>
      <tr>
        <td colspan="2" align="center">
		<div id="search-city-all">
			<select name="city" id="city" style="width:145px;">
				<option value="">..Select City..</option>
			</select>		
		</div></td>
        </tr>
      <tr>
        <td width="50%" align="center">
        <input type="text" name="priceFrom" id="priceFrom" style="width:60px;" value="Min" onBlur="putIndicator(this,'Min')" onFocus="clearIndicator(this,'Min')" onClick="clearIndicator(this,'Min')">		</td>
        <td width="50%" align="center">
         <input type="text" name="priceTo" id="priceTo" style="width:60px;"  value="Max" onBlur="putIndicator(this,'Max')" onFocus="clearIndicator(this,'Max')" onClick="clearIndicator(this,'Max')">		</td>
      </tr>
      <tr>
        <td colspan="2" align="center">Price range</td>
        </tr>
    </table></td>
  </tr>
</table>
</form></div>
    <div class="TabbedPanelsContent"><form name="formSearchOnline" id="formSearchOnline" method="post" action="">
 <input type="hidden" name="sg" id="sg" value="online"> 
 <input type="hidden" name="spage" id="spage" value="<?php echo $searchpage; ?>"> 
 <table width="100%" border="0">
  	  <tr>
    	<td width="63%"><input type="text" name="key" id="key" value="<?php 
	if(!empty($_GET['key']))
	 echo $_GET['key']; ?>"  />&nbsp; <input type="submit" value="Search" name="btnSrch" onClick="funSearchAll('formSearchOnline');"/> </td>
    	<td width="37%"><table width="100%" border="0">
  	  <tr>
      <td height="22">&nbsp;</td>
  	  </tr>
      <tr>
        <td width="50%" align="center">
        <input type="text" name="priceFrom" id="priceFrom" style="width:60px;" value="Min" onBlur="putIndicator(this,'Min')" onFocus="clearIndicator(this,'Min')" onClick="clearIndicator(this,'Min')">
		</td>
        <td width="50%" align="center">
         <input type="text" name="priceTo" id="priceTo" style="width:60px;" value="Max" onBlur="putIndicator(this,'Max')" onFocus="clearIndicator(this,'Max')" onClick="clearIndicator(this,'Max')">
		</td>
      </tr>
      <tr>
        <td colspan="2" align="center">Price range</td>
        </tr>
        <tr>
      <td height="22">&nbsp;</td>
  	  </tr>
    </table></td>
  </tr>
</table>
</form>
</div>
    <div class="TabbedPanelsContent"><form name="formSearchLocal" id="formSearchLocal" method="post" action="">
<input type="hidden" name="sg" id="sg" value="local">
<input type="hidden" name="spage" id="spage" value="<?php echo $searchpage; ?>">
<table width="100%" border="0">
  <tr>
    <td width="63%"><input type="text" name="key" id="key"  value="<?php 
	if(!empty($_GET['key']))
	 echo $_GET['key']; ?>" />&nbsp; <input type="submit" value="Search" name="btnSrch" onClick="funSearchAll('formSearchLocal');"/> </td>
    <td width="37%"><table width="100%" border="0">
      <tr>
        <td colspan="2" align="center">
			<select name="state" id="state" style="width:145px;" onChange="funSelectCity(this.value,'search-city-local');">
				<option value="">..Select State..</option>
				<?php			   
				   $sqlSelState="SELECT * FROM tbl_state where country_id='213'";
				   $rstSelState=mysql_query($sqlSelState);
				   while($rowSelState=mysql_fetch_array($rstSelState))
				   {
				   $st_id=$rowSelState['stateid'];
				   $st_name=$rowSelState['statename'];
				   echo "<option value='$st_id'>$st_name</option>";
				   }
				?>
			</select>	
		</td>
        </tr>
      <tr>
        <td colspan="2" align="center">
			<div id="search-city-local">
				<select name="city" id="city" style="width:145px;">
					<option value="">..Select City..</option>
				</select>		
			</div>
		</td>
        </tr>
      <tr>
        <td width="50%" align="center">
        <input type="text" name="priceFrom" id="priceFrom" style="width:60px;" value="Min" onBlur="putIndicator(this,'Min')" onFocus="clearIndicator(this,'Min')" onClick="clearIndicator(this,'Min')">
		</td>
        <td width="50%" align="center">
         <input type="text" name="priceTo" id="priceTo" style="width:60px;" value="Max" onBlur="putIndicator(this,'Max')" onFocus="clearIndicator(this,'Max')" onClick="clearIndicator(this,'Max')">
		</td>
      </tr>
      <tr>
        <td colspan="2" align="center">Price range</td>
        </tr>
    </table></td>
  </tr>
</table>
</form></div>
    <div class="TabbedPanelsContent"><form name="formSearchBuyer" id="formSearchBuyer" method="post" action="">
<input type="hidden" name="sg" id="sg" value="<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>">	
<input type="hidden" name="spage" id="spage" value="0">
<table width="100%" border="0">
  <tr>
    <td width="63%"><input type="text" name="key" id="key"  value="<?php 
	if(!empty($_GET['key']))
	 echo $_GET['key']; ?>" />&nbsp; <input type="submit" value="Search" name="btnSrch" onClick="funSearchAll('formSearchBuyer');"/> </td>
    <td width="37%"><table width="100%" border="0">
      <tr>
        <td colspan="2" align="center">
			<select name="state" id="state" style="width:145px;" onChange="funSelectCity(this.value,'search-city-buyer');">
				<option value="">..Select State..</option>
				<?php			   
				   $sqlSelState="SELECT * FROM tbl_state where country_id='213'";
				   $rstSelState=mysql_query($sqlSelState);
				   while($rowSelState=mysql_fetch_array($rstSelState))
				   {
				   $st_id=$rowSelState['stateid'];
				   $st_name=$rowSelState['statename'];
				   echo "<option value='$st_id'>$st_name</option>";
				   }
				?>
			</select>	
		</td>
        </tr>
      <tr>
        <td colspan="2" align="center">
			<div id="search-city-buyer">
				<select name="city" id="city" style="width:145px;">
					<option value="">..Select City..</option>
				</select>		
			</div>
		</td>
        </tr>
         <tr>
        <td width="50%" align="center">
        <input type="text" name="priceFrom" id="priceFrom" style="width:60px;" value="Min" onBlur="putIndicator(this,'Min')" onFocus="clearIndicator(this,'Min')" onClick="clearIndicator(this,'Min')">
		</td>
        <td width="50%" align="center">
         <input type="text" name="priceTo" id="priceTo" style="width:60px;" value="Max" onBlur="putIndicator(this,'Max')" onFocus="clearIndicator(this,'Max')" onClick="clearIndicator(this,'Max')">
		</td>
      </tr>
      <tr>
        <td colspan="2" align="center">Price range</td>
        </tr>
    </table></td>
  </tr>
</table>
</form></div>
  </div>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
<?php
 if(!empty($_GET['sg']))
 {
  if($_GET['sg']=="all")
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(0,1,"TabbedPanels1")';
  else if($_GET['sg']=="online")
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(1,1,"TabbedPanels1")';
  else if($_GET['sg']=="local")
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(2,1,"TabbedPanels1")';
  else if($_GET['sg']=="buyer")
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(4,1,"TabbedPanels1")';
   else if($_GET['sg']=="merchant")
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(4,1,"TabbedPanels1")';
  }
  
  
  else
   echo 'var TabbedPanels1 = new Spry.Widget.TabbedPanels(0,1,"TabbedPanels1")';
?> 
//-->
</script>
